package com.dime.basic.api.factory;


import com.dime.basic.api.RemoteBaseCombService;
import com.dime.basic.api.RemoteHarmService;
import com.dime.basic.api.domain.DimeBaseharm;
import com.dime.basic.api.model.Combo;
import com.dime.basic.api.model.HarmType;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Component
public class RemoteHarmFallbackFactory implements FallbackFactory<RemoteHarmService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteBaseCombFallbackFactory.class);

    @Override
    public RemoteHarmService create(Throwable cause) {
        log.error("蝶美基础信息危害服务调用失败:{}", cause.getMessage());
        return new RemoteHarmService() {
            @Override
            public R<List<HarmType>> getAllHarmTypes() {
                return R.fail("查询危害列表:" + cause.getMessage());
            }

            @Override
            public R<DimeBaseharm> getHarmByCode(String harmCode) {
                return R.fail("查询危害详细信息:" + cause.getMessage());
            }

            @Override
            public R<List<DimeBaseharm>> getHarmsByCodes(String[] harmCode) {
                return R.fail("编号查询危害详细信息:" + cause.getMessage());
            }

            @Override
            public R<List<DimeBaseharm>> getHarmsByIds(String[] Ids) {
                return R.fail("ID查询危害详细信息:" + cause.getMessage());
            }
        };
    }
}
